/**
 * Created by Michael on 2017/2/13.
 */
//单页面应用程序，使用路由进行管理
(function (angular) {
    //主模块
    var app=angular.module('mainApp',[
        'ngRoute',
        'appHttp',
        'mainApp.in_theaters',
        'mainApp.subject'
    ])
    //配置路由
    console.log('主模块');
    app.config(['$routeProvider','$locationProvider', function ($routeProvider,$locationProvider) {
        $locationProvider.hashPrefix('');
        $routeProvider.
        when('/movie/:type/:page?',{

                templateUrl:'js/in_theaters/template.html',
                controller: 'in_theatersCtrl'
        }).
        when('/subject/:id',{
            templateUrl:'js/subject/template.html',
            controller: 'subjectCtrl'
        }).
        otherwise({
            redirectTo:'/movie/in_theaters'
        })

    }]);
    //搜索控制器
    app.controller('searchCtrl', ['$scope','$route',function ($scope,$route) {
        $scope.searchText='';
        $scope.search= function () {
            if( $scope.searchText.length>0){
                $route.updateParams({
                    "type":'search',
                    'q':$scope.searchText
                })
                $scope.searchText='';
            }

        }



    }])
})(angular)